package net.factoryOpen.quickfactory.manufacturing.bas.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import net.factoryOpen.quickfactory.manufacturing.bas.domain.BasPayPattern;
import net.factoryOpen.quickfactory.manufacturing.bas.service.IBasPayPatternService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *
 * @author factoryOpen
 * @date 2025-06-01
 * @version 1.0.0-draft.0
 */
@RestController
@RequestMapping("/bas/payPattern")
public class BasPayPatternController extends BaseController
{
    @Autowired
    private IBasPayPatternService basPayPatternService;

/**
 * 查询付款方式列表
 */
//@PreAuthorize("@ss.hasPermi('bas:payPattern:list')")
@GetMapping("/list")
    public TableDataInfo list(BasPayPattern basPayPattern)
    {
        //startPage();
        List<BasPayPattern> list = basPayPatternService.selectBasPayPatternList(basPayPattern);
        return getDataTable(list);
    }

    /**
     * 导出付款方式列表
     */
//    @PreAuthorize("@ss.hasPermi('bas:payPattern:export')")
    @Log(title = "付款方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasPayPattern basPayPattern)
    {
        List<BasPayPattern> list = basPayPatternService.selectBasPayPatternList(basPayPattern);
        ExcelUtil<BasPayPattern> util = new ExcelUtil<BasPayPattern>(BasPayPattern.class);
        util.exportExcel(response, list, "付款方式数据");
    }

    /**
     * 获取付款方式详细信息
     */
//    @PreAuthorize("@ss.hasPermi('bas:payPattern:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(basPayPatternService.selectBasPayPatternById(id));
    }

    /**
     * 新增付款方式
     */
//    @PreAuthorize("@ss.hasPermi('bas:payPattern:add')")
    @Log(title = "付款方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasPayPattern basPayPattern)
    {
        return toAjax(basPayPatternService.insertBasPayPattern(basPayPattern));
    }

    /**
     * 修改付款方式
     */
//    @PreAuthorize("@ss.hasPermi('bas:payPattern:edit')")
    @Log(title = "付款方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasPayPattern basPayPattern)
    {
        return toAjax(basPayPatternService.updateBasPayPattern(basPayPattern));
    }

    /**
     * 删除付款方式
     */
//    @PreAuthorize("@ss.hasPermi('bas:payPattern:remove')")
    @Log(title = "付款方式", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basPayPatternService.deleteBasPayPatternByIds(ids));
    }
}
